//
//  NetManager+ServerURL.swift
//  SReader
//
//  Created by JunMing on 2021/6/19.
//  
//

import UIKit

extension NetManager {
    /// 获取登录/注册短信验证码
    static func serp(serp: String, callback: Completion<BaseModel<LoginModel>>?) {
        struct Parameter: Encodable {
            var serp: String
            var stellmost: String
            var forincludingarian: String
        }
        let p = Parameter(serp: serp, stellmost: Int.random, forincludingarian: Int.random)
        let request = HttpRequest(doman: .remote, target: .serp)
        requestModel(url: request, method: .POST, postData: p, completion: callback)
    }
    
    /// 验证码登陆/注册
    static func login(amoracity: String, agency: String, callback: Completion<BaseModel<LoginModel>>?) {
        struct Parameter: Encodable {
            var amoracity: String
            var agency: String
            var androfingero: String
            var haurfuture: String
        }
        let p = Parameter(amoracity: amoracity, agency:agency, androfingero: Int.random, haurfuture: Int.random)
        let request = HttpRequest(doman: .remote, target: .login)
        requestModel(url: request, method: .POST, postData: p, completion: callback)
    }
    
    /// 验证码登陆/注册
    static func logout(callback: Completion<BaseModel<LoginModel>>?) {
        struct Parameter: Encodable {
            var scalship: String
            var matterion: String
        }
        let p = Parameter(scalship: Int.random, matterion: Int.random)
        let request = HttpRequest(doman: .remote, target: .logout)
        requestModel(url: request, method: .GET, postData: p, completion: callback)
    }
    
    /// 验证码登陆/注册
    static func cancelAccount(callback: Completion<BaseModel<LoginModel>>?) {
        struct Parameter: Encodable {
            var phonetpickain: String
        }
        let p = Parameter(phonetpickain: Int.random)
        let request = HttpRequest(doman: .remote, target: .cancelAccount)
        requestModel(url: request, method: .GET, postData: p, completion: callback)
    }
    
    /// 获取需要环境并检查域名是否可用
    static func dominior(remainen: String, agonfication: String, congressality:String, callback: Completion<BaseModel<LoginModel>>?) {
        struct Parameter: Encodable {
            var remainen: String
            var agonfication: String
            var congressality: String
        }
        let p = Parameter(remainen: remainen, agonfication: agonfication, congressality: congressality)
        let request = HttpRequest(doman: .remote, target: .serp)
        requestModel(url: request, method: .POST, postData: p, completion: callback)
    }
    
    /// 获取需要环境并检查域名是否可用
    static func idfa(idfa: String, callback: Completion<BaseModel<LoginModel>>?) {
        struct Parameter: Encodable {
            var idfa: String
        }
        let p = Parameter(idfa: idfa)
        let request = HttpRequest(doman: .remote, target: .idfa)
        requestModel(url: request, method: .POST, postData: p, completion: callback)
    }
    
    /// APP首页
    static func herbive(callback: Completion<BaseModel<HomeModel>>?) {
        struct Parameter: Encodable {
            var claustr: String
        }
        let p = Parameter(claustr: Int.random)
        let request = HttpRequest(doman: .remote, target: .herbive)
        requestModel(url: request, method: .GET, postData: p, completion: callback)
    }
    
}
